<template>
	<view class="content">
		<u-navbar
			title="企业资质" 
			:bg-color="`${mainColor}`" 
			fixed 
			placeholder 
			autoBack
			:height="navigationBarHeight"
			:title-style="{color:`${textColor}`, fontSize:'16px', fontWeight:700}"
			:left-icon-color="`${textColor}`"
			v-if="showTitle"
			/>
		<scroll-view scroll-y enable-back-to-top show-scrollbar="false"
			:style="{height: `calc(100vh - ${navHeight}px)`}">
			<view class="ab_content" :style="{paddingBottom: `calc(78px + ${bottomHeight}px)`}" v-if="data.content">
				<view v-for="(item, index) in data.content" :key="index">
					<view class="about_tit">
						{{item.name}}
					</view>
					<view class="about_cont" v-if="item.description">
						{{item.description}}
					</view>
					<view
					  v-for="(image, index) in item.images"
					  :key="index"
					  class="image-wrapper"
					  :style="{ paddingTop: getPaddingTop(image) }"
					  v-if="item.images"
					>
					  <view
						v-if="!image.loaded"
						class="placeholder"
					  ></view>
				
					  <image
						:src="baseUrl(image.url)"
						class="real-image"
						@load="image.loaded = true"
					  />
					</view>
				</view>
			</view>	
		</scroll-view>
		<view class="fix-bottm" :style="{bottom:`${bottomHeight}px`}" v-if="platform != 'MP-ALIPAY'">
			<u-button :color="`${mainColor}`" shape="circle" @click="showCooperate=true"
				:custom-style="{color: `${textColor}`}">合作咨询</u-button>
		</view>
		<u-popup mode="center" :show="showCooperate" @close="showCooperate=false"
			custom-style="border-radius: 10px;" closeable>
			<view class="tan-box">
				<view class="wx-account">
					<text class="text1">
						微信号：
					</text>
					{{data.wechat_id}}
				</view>
				<image :src="baseUrl(data.contact_qrcode)" class="qrcode"></image>
				<view class="text2">
					工作时间：
				</view>
				<view class="text2">
					{{data.work_time}}
				</view>
				<view class="text2">
					非工作时间请耐心等待
				</view>
				<view class="btn">
					<u-button :color="`${mainColor}`" :custom-style="{borderRadius: '10px', color:`${textColor}`}"
						@click="copyWechat">复制微信号</u-button>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import { systemInfo } from '@/utils/mixin';
	import { baseUrl, getEnterpriseQualification } from '@/api';

	export default {
		mixins: [systemInfo],
		data() {
			return {
				baseUrl,
				showCooperate: false,
				data: {},
				platform: undefined
			}
		},
		onLoad() {
			this.getSystemInfo();
			this.loadDetail();
		},
		methods: {
			async loadDetail() {
				const res = await getEnterpriseQualification();
				this.data = res.data;
			},
			getPaddingTop(image) {
			    const ratio = (image.height / image.width) * 100;
			    return `${ratio.toFixed(6)}%`;
			},
			copyWechat() {
				uni.setClipboardData({
				    data: this.data.wechat_id,
				    success: function () {
						uni.showToast({
							title:'复制成功',
							icon:'none'
						})
				    }
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		background-color: #fff;
		overflow: hidden;
	}
	
.ab_content {
	padding: 20px 10px 78px;
	background-color: #fff;
	
	.about_tit {
	    text-align: left;
	    font-size: 16px;
	    line-height: 16px;
	    margin-bottom: 5px;
	    height: 17px;
	    font-weight: 500;
	    padding-left: 6px;
	    display: block;
	    border-left: 3px solid $main-color;
	}
	
	.about_cont {
	    display: block;
	    color: #e33233;
	    font-size: 13px;
	    text-align: justify;
	}
	
	.image-wrapper {
	  position: relative;
	  width: 100%;
	  overflow: hidden;
	  margin-top: 10px;
	  margin-bottom: 20px;
	}
	
	.placeholder {
	  position: absolute;
	  top: 0;
	  left: 0;
	  width: 100%;
	  height: 100%;
	  background-color: #f9f9f9;
	}
	
	.real-image {
	  position: absolute;
	  top: 0;
	  left: 0;
	  width: 100%;
	  height: 100%;
	}
}

.fix-bottm {
    position: fixed;
    bottom: 0;
    left: 0;
	right: 0;
    padding: 10px;
    box-sizing: border-box;
	background-color: #fff;
}

.tan-box {
    width: 260px;
    border-radius: 5px;
    padding: 20px;
    text-align: center;
    font-family: Times New Roman;
	
	.qrcode {
	    width: 135px;
	    height: 135px;
	    margin: 20px auto 5px;
	}
	
	.text2 {
	    font-size: 14px;
	    padding: 5px 0;
	}
	
	.btn {
	    width: 208px;
	    margin: 10px auto 0;
	}
}
</style>
